<template>
  <div>
    <div>
      <el-table stripe :data="tableData" border>
        <el-table-column prop="examPaperAnswer.id" label="ID" fixed/>
        <el-table-column prop="examPaper.name" label="试卷名称"/>
        <el-table-column prop="user.userName" label="用户名称"/>
        <el-table-column prop="examPaperAnswer.userScore" label="得分"/>
        <el-table-column prop="examPaperAnswer.correctCount" label="做对题数"/>
        <el-table-column label="操作" fixed="right" min-width="150">
          <template slot-scope="scope">
            <el-button type="primary" plain @click="handleEdit(scope.$index, scope.row)">批改</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>

export default {
  name: "AnswerPaperDoing",
  data() {
    return {
      tableData: [],
    }
  },
  mounted() {
    this.queryRequest();
  },
  methods: {
    queryRequest() {
      const url = '/answerPapers';
      this.axios.get(url, {
        params: {
          status: 1,
        }
      }).then(resp => {
        this.tableData = resp.data;
      })
    },
    handleEdit(index, row) {
      this.$router.push({
        name: 'AnswerPaperEdit', params: {
          examPaperName: row.examPaper.name,
          answerPaperId: row.examPaperAnswer.id,
        }
      });
    },
  },
}
</script>

<style scoped>
.el-input {
  width: 200px;
  margin-right: 10px;
}

.el-table {
  margin: 10px 0;
}
</style>